#ifndef HISTORYDIALOG_H
#define HISTORYDIALOG_H

#include <QDialog>
#include <QComboBox>
#include "classes/chathistory.h"

namespace Ui {
    class HistoryDialog;
}

class HistoryDialog : public QDialog
{
    Q_OBJECT

public:
    explicit HistoryDialog(QWidget *parent = nullptr);
    ~HistoryDialog();
    void initDateComboBox(QComboBox* dateComboBox, QDate& newestDate);
    void insertTable(const QDateTime& dateTime, const int index, const QString& content);
    void insertTableByChatHistory(const QString& keyword, const QString& historyPath);
    void syncHistoryDirPath(const QString& historyDirPath);
    void reloadHistoryTable(const QString& keyword);
    void reloadHistoryTable(
        const QString& keyword, const QDateTime& dateTime, bool isStartDateTime
    );
    bool reloadHistoryTable(
        const QString& keyword, const QDateTime& startDateTime, const QDateTime& endDateTime
    );
signals:
    void signal_showHistory(const ChatHistory& chatHistory, int index);
    
private slots:
    void on_pushButtonSearch_clicked();
    
    void on_tableWidgetHistory_cellActivated(int row, int);
    
private:
    Ui::HistoryDialog *ui;
    QString historyDirPath;
    const char* DATE_DISPLAY_FORMAT = "yyyy-MM-dd HH:mm:ss";
};

#endif // HISTORYDIALOG_H
